﻿using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace VideoMergeSplitApp.ui.dialog
{
    public partial class InputDialogBox2 : Form
    {

        public string res = "";

        public InputDialogBox2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            if (!string.IsNullOrWhiteSpace(maskedTextBox1.Text.Replace(":","")) && maskedTextBox1.Text.Replace(":", "").Length == 6)
            {
                res = maskedTextBox1.Text;
                Close();
            }
        }

        private void maskedTextBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsDigit(e.KeyChar) && e.KeyChar != '\b') // 判断按键是否为数字或退格键
            {
                e.Handled = true; // 阻止字符的输入
            }
        }

        private void InputDialogBox2_Load(object sender, EventArgs e)
        {

            Task.Run(() =>
            {
                Thread.Sleep(300);
                this.Invoke(new Action(() =>
                {
                    maskedTextBox1.Focus(); // 设置焦点到TextBox
                    maskedTextBox1.Select(0, 0); // 将光标移动到第一位

                }));
            });

            
        }
    }
}
